﻿Public Class MainMenu
    Dim t As Int16
    Dim co = 0
    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        Menulist2.Renderer = New MyRenderer
        Menulist2.ForeColor = Color.WhiteSmoke
        Toolfile.DropDown.ForeColor = Color.FromArgb(67, 96, 156)
        'MenuList.Renderer = New MyRenderer
        MenuList.ForeColor = Color.WhiteSmoke
        'FacebookButton1.Visible = False
        'btnnewtap.Visible = False
        AddForm(panelshow, frmStartup)
        'AddForm(panelshow, frmSale)
        loadbyuser()
        loadMaquee()
    End Sub
    Private Sub loadMaquee()
        Dim text As String = Cmd.ExecuteScalar("select declaration from  tbl_declare")
        lblmarquee.Text = text
    End Sub
    Private Sub loadbyuser()
        Toolusername.Text = frmLogin.user
        Dim ugroup = frmLogin.groupid
        Select Case ugroup
            Case 1

            Case 2
                tsystem.Visible = False
                'tmanage.Visible = False
                treport.Visible = False
                tpayment.Visible = False
            Case 3
                tsystem.Visible = False
                'tmanage.Visible = False
                treport.Visible = False
                ' tpayment.Visible = False

        End Select
    End Sub

    Private Sub ExitTool_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fileexit.Click
        Application.Exit()
    End Sub

    Private Sub treport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles treport.Click
        AddForm(panelshow, frmReport)
        changecolor(treport)
        'FacebookButton1.Visible = False
        'btnnewtap.Visible = False
    End Sub

    Private Sub lclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lclear.Click
        'panelshow.Controls.Clear()
        'FacebookButton1.Visible = False
        'btnnewtap.Visible = False
    End Sub

    Private Sub ttransaction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ttransaction.Click
        AddForm(panelshow, frmTransaction)
        changecolor(ttransaction)
        'btnnewtap.Visible = True
        'If t = 1 Then
        '    btnnewtap.Visible = False
        '    FacebookButton1.Visible = True
        'End If
    End Sub

    Private Sub tsystem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsystem.Click
        AddForm(panelshow, frmSystem)
        changecolor(tsystem)
        'FacebookButton1.Visible = False
        'btnnewtap.Visible = False
    End Sub
    

    Private Sub tmanage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmanage.Click
        AddForm(panelshow, frmManages)
        changecolor(tmanage)
        'FacebookButton1.Visible = False
        'btnnewtap.Visible = False
    End Sub

    Private Sub changecolor(ByVal tm As ToolStripItem)
        For i = 0 To MenuList.Items.Count - 1
            MenuList.Items(i).BackColor = Color.FromArgb(67, 96, 156)
            MenuList.Items(i).ForeColor = Color.WhiteSmoke
        Next
        tm.BackColor = Color.FromArgb(240, 240, 240) 'Color.Goldenrod
        tm.ForeColor = Color.FromArgb(67, 96, 156)
    End Sub

    Private Sub Toolabout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Toolabout.Click
        'frmAbout.ShowDialog()
        AddForm(panelshow, frmStartup)
    End Sub

    'Private Sub btnnewtap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnewtap.Click
    '    frmTransaction.tapsale.TabPages.Insert(1, frmTransaction.tretail2)
    '    btnnewtap.Visible = False
    '    FacebookButton1.Visible = True
    '    t = 1
    'End Sub

    'Private Sub FacebookButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FacebookButton1.Click
    '    frmTransaction.tapsale.TabPages.Remove(frmTransaction.tretail2)
    '    btnnewtap.Visible = True
    '    FacebookButton1.Visible = False
    '    t = 0
    'End Sub

    Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
        Application.Exit()
    End Sub
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        khmertime(lbltime)
    End Sub

    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        panelshow.Controls.Clear()
        'FacebookButton1.Visible = False
        'btnnewtap.Visible = False
    End Sub

    Private Sub MainMenu_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        Application.Exit()
    End Sub

    Private Sub lblcolapse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblcolapse.Click
        If co = 0 Then
            SplitContainer1.Panel1Collapsed = True
            co = 1
        Else
            SplitContainer1.Panel1Collapsed = False
            co = 0
        End If
    End Sub

    Private Sub tmainmenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmainmenu.Click

    End Sub
    'Dim TPos As Integer
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        'Dim mystr As String
        'mystr = "Testing for My Marquee.."
        'If TPos = 0 Or TPos > Len(mystr) Then TPos = 1
        'lblmarquee.Text = Mid(mystr, TPos)
        'TPos = TPos + 1
        If (lblmarquee.Left) + (lblmarquee.Width) <= 0 Then
            lblmarquee.Left = Me.Width
        End If
        lblmarquee.Left = (lblmarquee.Left) - 1

    End Sub

    Private Sub filelogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles filelogout.Click

        frmLogin.Visible = True
        frmLogin.user = "N/A"
        frmLogin.userid = 0
        frmLogin.groupid = 0
        ' Me.Close()
    End Sub
End Class